package cn.lili.modules.payment.entity.vo;

import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.common.utils.BeanUtil;
import cn.lili.common.utils.StringUtils;
import cn.lili.modules.payment.entity.dto.CashierParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * 充值收银台参数
 *
 * @author liushuai(liushuai711 @ gmail.com)
 * @version v4.0
 * @Description:
 * @since 2023/6/13 11:50
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RechargeCashierParamVO extends CashierParam {

    static final Long MAX_DETAIL_LENGTH = 30L;

    @ApiModelProperty(value = "价格")
    private Double price;

    @ApiModelProperty(value = "支付title")
    private String title;

    @ApiModelProperty(value = "支付详细描述")
    private String detail;

    @ApiModelProperty(value = "订单sn集合")
    private String orderSn;


    @ApiModelProperty(value = "订单创建时间")
    private Date createTime;

    @ApiModelProperty(value = "支付自动结束时间")
    private Long autoCancel;


    public String getDetail() {
        if (CharSequenceUtil.isEmpty(detail)) {
            return "在线充值";
        }
        return StringUtils.filterSpecialChart(StringUtils.sub(detail, 30));
    }

    public RechargeCashierParamVO(CashierParam cashierParam) {
        BeanUtil.copyProperties(cashierParam, this);
    }
}
